package org.ix.gateway.route.controller;

import org.ix.gateway.route.service.GatewayRoutesVersionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


@Api(tags = {"网关路由版本相关接口"})
@CrossOrigin
@RequestMapping("/gateway-routes-version")
@RestController
@Validated
public class GatewayRoutesVersionController {

    private final GatewayRoutesVersionService gatewayRoutesVersionService;

    @Autowired
    public GatewayRoutesVersionController(GatewayRoutesVersionService gatewayRoutesVersionService) {
        this.gatewayRoutesVersionService = gatewayRoutesVersionService;
    }

    @ApiOperation(value = "根据路由最新版本号", notes = "根据路由最新版本号")
    @GetMapping("/get-last-version")
        public ResponseEntity<Long> getLastVersion() {
        Long lastVersion = gatewayRoutesVersionService.getLastVersion();
        return ResponseEntity.ok(lastVersion);
    }
}
